package so.sao.code.service.infrastructure.enums;

import so.sao.top.core.util.enums.NamedEnumEntity;

public enum PrintFileFieldConfigGroup implements NamedEnumEntity<String> {
	CodeUrl("code_url", "域名"), FriendlyCodeAndCodeUrl("friendly_code|code_url", "加密|域名"), CodeUrlAndFriendlyCode(
			"code_url|friendly_code",
			"域名|加密"), SeqnumAndCodeUrl("seqnum|code_url", "序号|域名"), CodeUrlAndSeqnum("code_url|seqnum",
					"域名|序号"), FriendlyCodeFrontAndCodeUrlAndFriendlyCodeEnd(
							"friendly_code_front|code_url|friendly_code_end",
							"1加密|域名|2加密"), PackageCodeUrl("package_code_url", "箱码");

	private String id;
	private String name;

	private PrintFileFieldConfigGroup(String id, String name) {
		this.id = id;
		this.name = name;
	}

	@Override
	public String getValue() {
		return id;
	}

	@Override
	public String getName() {
		return name;
	}

	public static PrintFileFieldConfigGroup fromValue(String id) {
		switch (id) {
		case "code_url":
			return CodeUrl;
		case "friendly_code|code_url":
			return FriendlyCodeAndCodeUrl;
		case "code_url|friendly_code":
			return CodeUrlAndFriendlyCode;
		case "seqnum|code_url":
			return SeqnumAndCodeUrl;
		case "code_url|seqnum":
			return CodeUrlAndSeqnum;
		case "friendly_code_front|code_url|friendly_code_end":
			return FriendlyCodeFrontAndCodeUrlAndFriendlyCodeEnd;
		case "package_code_url":
			return PackageCodeUrl;
		default:
			throw new IllegalArgumentException("Value [" + id + "] not support!");
		}
	}
}
